package com.example.rae.service.impl;

import com.example.rae.base.BaseApiService;
import com.example.rae.base.ResponseBase;
import com.example.rae.entity.UserEntity;
import com.example.rae.service.IMemberService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author YangZeRong
 * @Date 2022/4/9 18:35
 * @Version 1.0
 */
@RestController
public class IMemberServiceImpl extends BaseApiService implements IMemberService {

    @Value("${server.port}")
    private String serverPort;

    @RequestMapping("/getMember")
    @Override
    public UserEntity getMember(@RequestParam("name") String name) {
        UserEntity user = new UserEntity();
        user.setName(name + "，端口号：" + serverPort);
        user.setAge(24);
        return user;
    }

    @RequestMapping("/getUserInfo")
    @Override
    public ResponseBase getUserInfo() {
        try {
            // 会员服务产生1.5s的延迟
            Thread.sleep(1500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return setResultSuccess("处理成功", "订单服务调用会员服务成功");
    }
}
